package com.ruoyi.system.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysBoatWater;
import com.ruoyi.system.mapper.SysBoatWaterMapper;
import com.ruoyi.system.service.SysBoatWaterService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author syj
 * @description 针对表【sys_boat_water】的数据库操作Service实现
 * @createDate 2022-09-02 17:10:00
 */
@Service
public class SysBoatWaterServiceImpl extends ServiceImpl<SysBoatWaterMapper, SysBoatWater>
        implements SysBoatWaterService {

    @Override
    public AjaxResult getBoatWaterList(SysBoatWater param) {
        List<SysBoatWater> sysBoatWaters = baseMapper.selectList(Wrappers.<SysBoatWater>lambdaQuery()
                .eq(StrUtil.isNotBlank(param.getBoatSn()), SysBoatWater::getBoatSn, param.getBoatSn())
                .eq(ObjectUtil.isNotNull(param.getDeviceId()), SysBoatWater::getDeviceId, param.getDeviceId())
                .eq(ObjectUtil.isNotNull(param.getTaskId()), SysBoatWater::getTaskId, param.getTaskId())
                .eq(ObjectUtil.isNotNull(param.getCruiseId()), SysBoatWater::getCruiseId, param.getCruiseId())
                .eq(ObjectUtil.isNotNull(param.getLevel()), SysBoatWater::getLevel, param.getLevel())
                .ge(ObjectUtil.isNotNull(param.getStartTime()), SysBoatWater::getTime, param.getStartTime())
                .le(ObjectUtil.isNotNull(param.getEndTime()), SysBoatWater::getEndTime, param.getEndTime())
                .orderByAsc(SysBoatWater::getTime));
        return AjaxResult.success(sysBoatWaters);
    }
}




